using System;
using BencodeLibrary;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BencodeLibrary_Test
{
    [TestClass]
    public class TestBList
    {
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void BListAddNullValue()
        {
            BList list = new BList();

            list.Add(null);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void BListAddRangeNullValue()
        {
            BList list = new BList();

            list.AddRange(new IBencodingType[] { null });
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void BListAddRangeNull()
        {
            BList list = new BList();

            list.AddRange(null);
        }

        [TestMethod]
        public void BListAddRange()
        {
            BList list = new BList();

            list.AddRange(new IBencodingType[] { new BInt(1)  });
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void BListSetNullValue()
        {
            BList list = new BList();

            list.Add(new BInt(0));
            list[0] = null;
        }

        [TestMethod]
        public void BListSetValue()
        {
            BList list = new BList();

            list.Add(new BInt(0));
            BInt newInt = new BInt(1);
            list[0] = newInt;

            Assert.AreEqual(newInt, list[0]);
        }
    }
}